<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" th:src="@{/static/js/html5.js}"></script>
    <script type="text/javascript" th:src="@{/static/js/respond.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/lib/PIE-2.0beta1/PIE_IE678.js}"></script>
    <![endif]-->
    <link th:href="@{/static/lib/layui/css/layui.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{/static/css/jx-admin.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{/static/lib/jx-fonts/iconfont.css}" rel="stylesheet" type="text/css"/>

    <script type="text/javascript" th:src="@{/static/lib/jquery/1.9.1/jquery.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/lib/layui/layui.all.js}"></script><!--弹出框插件-->
    <script type="text/javascript" th:src="@{/static/js/jx.js}"></script>
    <script type="text/javascript" th:src="@{/static/js/jx-admin.js}"></script>

    <link th:href="@{/static/lib/layui/css/layui.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{/static/css/jx.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{/static/css/jx-admin.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{/static/lib/jx-fonts/iconfont.css}" rel="stylesheet" type="text/css"/>
    <title>路由列表</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <style rel="stylesheet" type="text/css">
        .layui-table-view .layui-table[lay-size=sm] .layui-table-cell {
            height: auto;
        }
    </style>
</head>

<body>
<div>
    <div class="x-nav">
        <span class="layui-breadcrumb" lay-separator=">">
            <a><i class="iconfont">&#xe67f;</i> 首页</a>
            <a>路由服务</a>
            <a><cite>路由列表</cite></a>
        </span>
        <!--<button class="layui-btn" style="margin-top:3px; float: right;" onclick="javascript:location.replace(location.href);"><i class="iconfont">&#xe650;</i>刷 新</button>-->
    </div>
    <div class="x-body">
        <xblock class="xblock-middle">
            <button class="layui-btn" onclick="show_full_page('新增路由','/gateway/route/page/add', 500, 400)"><i class="layui-icon">&#xe608;</i>新增路由</button>
            <button class="layui-btn" id="search" name="search" style="float: right;"><i class="layui-icon">&#xe615;</i>刷 新</button>
        </xblock>
        <table id="listTable" lay-filter="listTable"></table>
    </div>
</div>
    <script type="text/javascript" th:src="@{/static/lib/jquery/1.9.1/jquery.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/lib/layui/layui.all.js}"></script>
    <script type="text/javascript" th:src="@{/static/js/jx-admin.js}"></script>
    <script type="text/javascript" th:src="@{/static/js/md5.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/js/jx.js}"></script>
    <script type="text/html" id="execTpl">
        <a href="javascript:;" class="a-normal" onclick="show_full_page('编辑路由','/gateway/route/page/edit/{{d.id}}')">编辑</a>
    </script>
    <script type="text/html" id="instanceTpl">
        {{#  layui.each(d.instanceList, function(index, item){ }}
            <li><span>{{ item }}</span></li>
        {{#  }); }}
    </script>
    <script type="text/javascript">
        layui.use('table', function(){
            var table = layui.table;
            table.render({
                elem: '#listTable'
                ,even: true //开启隔行背景
                ,size: 'sm' //小尺寸的表格
                ,loading: true
                ,page: false //开启分页
                ,url: '[[@{/gateway/route/data/list}]]' //数据接口
                ,method: 'get'
                ,cols: [
                    [
                        {type: 'numbers', title: '序号'}
                        ,{field: 'normal', title: '实例名', width:200, templet: function(data) {
                            var content = data.name;
                            if (data.routeType.value == 0) {
                                content = "<span class='a-normal'>" + content + "</span>";
                            }
                            return content;
                            }
                        }
                        ,{field: 'path', title: '请求路径', width: 200}
                        ,{field: 'uri', title: 'uri'}
                        ,{field: 'order', title: 'order', width: 70}
                        ,{field: 'normal', title: '实例', width: 170, templet: "#instanceTpl"}
                        ,{type: 'normal', title: '操作', width: 80, templet: "#execTpl"}
                    ]
                ]
            });

            $("#search").click(function () {
                table.reload('listTable');
            });
        });
        function disable_route(routeId) {
            var url = '[[@{/gateway/route/disable}]]' + routeId;
            $.ajax({
                url: url,
                type: "PUT",
                dataType: "json",
                success: function(data) {

                }
            });
        }
    </script>
</body>
</html>